package tt.doubleagent;

import tt.doubleagent.game.GameController;
import tt.doubleagent.game.GameControllerV1;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;

public class GameSetupActivity extends Activity {

	private Button btnMinusPlayer;
	private Button btnPlusPlayer;
	private TextView tv_PlayerCount;
	private int mCurrentPlayer;
	private GameControllerV1 gameController;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_game_setup);
		initMembers();
		initEvent();
	}
	
	private void initMembers()
	{
	
		btnMinusPlayer=(Button)this.findViewById(R.id.btnMinusPlayers);
		btnPlusPlayer=(Button)this.findViewById(R.id.btnPlusPlayers);
		tv_PlayerCount=(TextView)this.findViewById(R.id.tv_PlayerCount);
		mCurrentPlayer=6;
		tv_PlayerCount.setText(String.valueOf(mCurrentPlayer));
		gameController=GameControllerV1.getInstance();
	}
	private void initEvent()
	{
		btnMinusPlayer.setOnClickListener(new OnClickListener(){

			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				mCurrentPlayer--;
				if(mCurrentPlayer==-1)
					mCurrentPlayer=0;
				
				tv_PlayerCount.setText(String.valueOf(mCurrentPlayer));
			}});
		
		btnPlusPlayer.setOnClickListener(new OnClickListener(){

			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				mCurrentPlayer++;
				if(mCurrentPlayer>gameController.TotalPlayersUpperThreshold)
					mCurrentPlayer=gameController.TotalPlayersUpperThreshold;
				tv_PlayerCount.setText(String.valueOf(mCurrentPlayer));
			}});
	}

}
